package com.aegis.common.dubbo;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.rpc.*;

import java.util.Arrays;

/**
 * @Author renogo
 * 
 * @Version 1.0
 * @Descritube
 */
@Slf4j
public class LoggingFilter implements Filter {
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        // 打印入参
        log.info("A服务入参: " + Arrays.toString(invocation.getArguments()));

        // 执行调用
        Result result = invoker.invoke(invocation);

        // 打印出参
        log.info("B服务出参: " + result.getValue());

        return result;
    }
}
